class Tool{
  static getName(int typeId,int deviceId) {
      String name;
      switch (typeId) {
        case 1:
          name = '灯 ${deviceId}';
          break;
        case 2:
          name = '窗帘 ${deviceId}';
          break;
        case 3:
          name = '门 ${deviceId}';
          break;
        case 4:
          name = '烟雾报警器 ${deviceId}';
          break;
        case 5:
          name = '电视 ${deviceId}';
          break;
        case 6:
          name = '空调 ${deviceId}';
          break;
        case 7:
          name = '温度计 ${deviceId}';
          break;
        case 8:
          name = '智能手环 ${deviceId}';
          break;
        default:
      }
      return name;
    }

  static getTime(String postTime) {
      // 传入数据库的时间数据，返回应该在设备表上显示的数据样式
      DateTime Ttime = DateTime.parse(postTime).add(new Duration(hours: 8));
      var time;
      DateTime nowTime = DateTime.now();
      if (nowTime.year == Ttime.year) {
        if (nowTime.difference(Ttime).inDays == 0) {
          time = '今天 ${Ttime.hour}:${Ttime.minute}';
        } else {
          if (nowTime.difference(Ttime).inDays == 1) {
            time = '昨天 ${Ttime.hour}:${Ttime.minute}';
          } else {
            time = '今年 ${Ttime.month}月${Ttime.day}日';
          }
        }
      } else {
        time = '${Ttime.year}年${Ttime.month}月';
      }
      return time;
    }
    static isRead(List list){
      for (var i = 0; i < list.length; i++) {
              list[0]['state']=1;
      }
    }
}